package com.xiaoyu.daggertest;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;

import com.xiaoyu.daggertest.bean.Person;
import com.xiaoyu.daggertest.bean.Weapon;
import com.xiaoyu.daggertest.bean.coldsteal.Arch;
import com.xiaoyu.daggertest.bean.coldsteal.Lance;
import com.xiaoyu.daggertest.bean.coldsteal.Sword;
import com.xiaoyu.daggertest.bean.gun.FireArm;
import com.xiaoyu.daggertest.bean.gun.Rifle;
import com.xiaoyu.daggertest.bean.gun.Spear;
import com.xiaoyu.daggertest.component.DaggerUseComponent;
import com.xiaoyu.daggertest.component.DaggerWeaponComponent;
import com.xiaoyu.daggertest.component.WeaponComponent;
import com.xiaoyu.daggertest.module.ColdSteelModule;
import com.xiaoyu.daggertest.module.GunModule;
import com.xiaoyu.daggertest.module.PersonModule;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

import javax.inject.Inject;

public class MainActivity extends AppCompatActivity {

    @Inject
    Person person;

    @Inject
    Lance lance;

    @Inject
    Spear spear;

    @Inject
    Arch arch;

    @Inject
    Sword sword;

    @Inject
    FireArm fireArm;

    @Inject
    Rifle rifle;

    List<Weapon> weapons = new ArrayList<>();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        DaggerUseComponent.builder().weaponComponent(App.getmWeaponComponent()).personModule(new PersonModule()).build().inject(this);

        weapons.add(lance);
        weapons.add(spear);
        weapons.add(arch);
        weapons.add(sword);
        weapons.add(fireArm);
        weapons.add(rifle);

        final Random random = new Random();

        findViewById(R.id.mBtnCutWeapon).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                final int i = random.nextInt(5);
                person.useWhatWeapon(MainActivity.this,weapons.get(i));
            }
        });


    }

}
